<% layout('/layouts/default.html', {title: '任务接收', libs: ['dataGrid']}){ %>
<div class="main-content">
    <div class="box box-main">

        <div class="box-body">
            <#form:form id="searchForm" model="${supIndexFive2}" action="${ctx}/feedback/dcSupTaskFeedback/feedbacklistData?taskId=${supIndexFive2.taskId}&actionId=${supIndexFive2.actionId}" method="post" class="form-inline"
            data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
            <!--<div class="form-group">
                <div class="control-inline">
                    <#form:input path="taskTitle" placeholder="请输入任务标题" maxlength="200" class="form-control width-120"/>
                </div>
            </div>
            <div class="form-group">
                <button type="submit" class="btn btn-primary btn-sm">${text('查询')}</button>
                <button type="reset" class="btn btn-default btn-sm">${text('重置')}</button>
            </div>-->

        </#form:form>
        <table id="dataGrid"></table>
        <div id="dataGridPage"></div>
    </div>
</div>
</div>
<% } %>
<script>
    // 初始化DataGrid对象
    $('#dataGrid').dataGrid({
        searchForm: $("#searchForm"),
        sortableColumn: false, // 列表不允许排序
        // showCheckbox: true,
        columnModel: [
            {header:'${text("反馈截止时间")}', name:'feedbackEndTimeStr', width:150, align:"center",
                formatter:'date', formatoptions:{srcformat:'Y-m-d H:i:s',newformat:'Y-m-d H:i'}},
            {header:'${text("反馈时间")}', name:'feedbackTimeStr', width:150, align:"center"},
            {header:'${text("任务标题")}', name:'taskTitle', width:150, align:"left", frozen:true, formatter: function(val, obj, row, act){
                if(row.taskId != null){
                    return '<a href="${ctx}/taskdeploy/dcSupTaskInfo/detailForm?id='+row.taskId+'" class="btnList" data-title="${text("督办任务信息")}">'+(val||'暂无标题')+'</a>';
                } else {
                    return row.taskTitle
                }
            }},
            {header:'${text("牵头责任单位")}', name:'leaderOrgName', width:150, align:"left"},
            {header:'${text("状态")}', name:'feedbackStatus', width:150, align:"center", formatter: function(val, obj, row, act){
                    return js.getDictLabel(${@DictUtils.getDictListJson('dc_feedback_status')}, val, '${text("未反馈")}', true);
                }},
            {
                header:'${text("逾期提醒")}', width:150, align:"left",formatter:function (val, obj, row, act) {
                    let startTime = new Date(row.feedbackEndTimeStr); // 开始时间  30
                    let endTime = new Date('${nowDate}'); // 结束时间  25
                    let usedTime =endTime - startTime; // 相差的毫秒数
                    let days = Math.floor(usedTime / (24 * 3600 * 1000)); // 计算出天数
                    // feedbackStatus
                    let status=row.feedbackStatus;
                    // 草稿状态 不显示
                    if(status==0||status==1){
                        return ""
                    }
                    //未反馈
                    if (status<2){
                        if (days==0){
                            if (endTime>startTime){
                                return "逾期未反馈";
                            }

                            return "今天之后将逾期";
                        }
                        if (days<0){
                            if (days<-15){
                                return "正常";
                            }
                            return Math.abs(days)+"天后逾期";
                        }
                        return "逾期未反馈";
                    }else {
                        let feedbackTime = new Date(row.feedbackTimeStr);
                        let fkdays = Math.floor((feedbackTime-startTime) / (24 * 3600 * 1000)); // 计算出天数
                        if (row.feedbackEndTimeStr==row.feedbackTimeStr){
                            return "正常";
                        }
                        if (feedbackTime>new Date(row.feedbackEndTimeStr)){
                            return "逾期反馈";
                        }
                        if (fkdays<=0){
                            return "正常";
                        }
                        if (fkdays>0){
                            return "逾期反馈";
                        }

                    }
                    return "";
                }
            },
            /*{header:'${text("状态")}', name:'hisStatus', width:150, align:"center"
                ,formatter: function(val, obj, row, act){
                    var actions = [];
                    if(row.hisStatus=="已完成") {
                    actions.push('<span style="color:green">'+val+'</span>');
                    }else {
                        actions.push('<span style="color:red">'+val+'</span>');
                    }
                    return actions.join('')
            }
            },*/
            {header:'${text("操作")}', name:'actions', width:260,align:"center", formatter: function(val, obj, row, act){
                    var actions = [];
                        actions.push('<a href="${ctx}/audit/taskReceive/taskReceiveOneView?remarks2=0&id='+row.id+'" class="btn btn-primary btn-xs btnList" title="${text("查看")}" ><span>查看</span></a>&nbsp;');
                return actions.join('');
            }}
    ],
    // 加载成功后执行事件
    ajaxSuccess: function(data){

    }
    });

</script>